package cn.hznc.controller.toolAnalyze;

import cn.hznc.controller.service.toolAnalyze.PersonnelUsageAnalysisService;
import cn.hznc.domain.entity.PersonnelUsageAnalysisEntity;
import cn.hznc.domain.request.toolAnalyze.PersonnelUsageAnalysisReq;
import cn.hznc.domain.response.PageResult;
import cn.hznc.domain.response.ResponseBody;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/personnelUsageAnalysis")
public class PersonnelUsageAnalysisController {
    @Resource
    private PersonnelUsageAnalysisService personnelUsageAnalysisService;
    @RequestMapping(value = "/queryPersonnelUsageConsume", method = RequestMethod.POST)
    public ResponseBody queryPersonnelUsageConsume(@RequestBody PersonnelUsageAnalysisReq personnelUsageAnalysisReq){
        return ResponseBody.success(personnelUsageAnalysisService.queryPersonnelUsageConsumeReload(personnelUsageAnalysisReq));
    }

    @RequestMapping(value = "/queryPersonnelUsageConsumeDetail", method = RequestMethod.POST)
    public ResponseBody queryPersonnelUsageConsumeDetail(@RequestBody PersonnelUsageAnalysisReq personnelUsageAnalysisReq){
        return ResponseBody.success(personnelUsageAnalysisService.queryPersonnelUsageConsumeDetail(personnelUsageAnalysisReq));
    }

    @RequestMapping(value = "/queryPersonnelUsageConsumeIndex", method = RequestMethod.POST)
    public ResponseBody queryPersonnelUsageConsumeIndex(@RequestBody PersonnelUsageAnalysisReq personnelUsageAnalysisReq){
        return ResponseBody.success(personnelUsageAnalysisService.queryPersonnelUsageConsumeIndex(personnelUsageAnalysisReq));
    }

    @RequestMapping(value = "/queryKnifeInstallation", method = RequestMethod.POST)
    public ResponseBody<PageResult<PersonnelUsageAnalysisEntity>> queryKnifeInstallation(@RequestBody PersonnelUsageAnalysisReq personnelUsageAnalysisReq){
        return ResponseBody.success(personnelUsageAnalysisService.queryKnifeInstallation(personnelUsageAnalysisReq));
    }
    @RequestMapping(value = "/queryPersonnelToolUsageAnalysisChart", method = RequestMethod.POST)
    public ResponseBody queryPersonnelToolUsageAnalysisChart(@RequestBody PersonnelUsageAnalysisReq personnelUsageAnalysisReq){
        try {
            return ResponseBody.success(personnelUsageAnalysisService.queryPersonnelToolUsageAnalysisChartReload(personnelUsageAnalysisReq));
        } catch (ParseException e) {
            return ResponseBody.error("10001" , e.getMessage());
        }
    }


    @RequestMapping(value = "/queryAllOperator", method = RequestMethod.POST)
    public ResponseBody<List<String>> queryAllOperator(@RequestBody PersonnelUsageAnalysisReq personnelUsageAnalysisReq){
        return ResponseBody.success(personnelUsageAnalysisService.queryAllOperatorReload(personnelUsageAnalysisReq));
    }
}
